package cn.hls.until;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @fileName: PropertiesUtil.java
 * @descrption: 读取properties通用类
 * @author : yinghui.zhang
 * @Email: uuhui@163.com
 * @date 2015-4-3
 * @version 1.0
 */
public class PropertiesUtil {
	private static Log logger = LogFactory.getLog(PropertiesUtil.class);

	private static Properties properties = null;
	static {
		InputStream in = null;
		try {
			properties = new Properties();
			String path = PropertiesUtil.class.getClassLoader().getResource("").toURI().getPath() + "redis.properties";
			in = new FileInputStream(new File(path));
			properties.load(in);
		} catch (Exception e) {
			logger.error("加载config.properties出错！");
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public static String read(String key) {
		return properties.get(key).toString();
	}

}
